package org.dandsoft.blackbox.laboratory.samples.lighter.view;

import javax.swing.*;
import java.awt.*;

import org.dandsoft.blackbox.laboratory.samples.lighter.World;

/**
 * Created by IntelliJ IDEA.
 * User: dvilyuzhanin
 * Date: 24.03.2009 1:46:14
 */
public class LighterStatePanel extends JPanel {
    private JLabel time = new JLabel("time: ");
    private JLabel sunXPosition = new JLabel("sunX: ");
    private JLabel sunYPosition = new JLabel("sunY: ");
    private JLabel topLightSensor = new JLabel("top: ");
    private JLabel rightLightSensor = new JLabel("right: ");
    private JLabel bottomLightSensor = new JLabel("bottom: ");
    private JLabel leftLightSensor = new JLabel("left: ");

    private World world;

    public LighterStatePanel(World world) {
        this.world = world;
        //setLayout(new FlowLayout());
        setLayout(new GridLayout(10, 1));
        add(time);
        add(sunXPosition);
        add(sunYPosition);
        add(topLightSensor);
        add(rightLightSensor);
        add(bottomLightSensor);
        add(leftLightSensor);
    }

    public void update() {
        time.setText("time: " + world.getTime());
        sunXPosition.setText("sunX: " + (int) world.getSun().getX());
        sunYPosition.setText("sunY: " + (int) world.getSun().getY());
        topLightSensor.setText("top: " + world.getLighter().getTop().getState());
        rightLightSensor.setText("right: " + world.getLighter().getRight().getState());
        bottomLightSensor.setText("bottom: " + world.getLighter().getBottom().getState());
        leftLightSensor.setText("left: " + world.getLighter().getLeft().getState());

    }
}
